package cn.edu.zafu.bigdata.x.hjn;

import java.util.List;

public class GenericUtils {

    public static <T extends Comparable<T>> T findMax(List<T> list) {
        if (list == null || list.isEmpty()) {
            throw new IllegalArgumentException("List cannot be null or empty");
        }

        T max = list.get(0); // 初始化最大值为列表的第一个元素
        for (T element : list) {
            if (element.compareTo(max) > 0) {
                max = element; // 更新最大值
            }
        }
        return max; // 返回最大值
    }
}

